package com.wngbms.aop._01;

import com.wngbms.aop.staticproxy.DefaultEchoService;
import com.wngbms.aop.staticproxy.EchoService;
import org.springframework.aop.framework.ProxyFactory;

public class ProxyFactoryDemo {

    public static void main(String[] args) {
        DefaultEchoService defaultEchoService = new DefaultEchoService();

        ProxyFactory proxyFactory = new ProxyFactory(defaultEchoService);
        proxyFactory.addAdvice(new EchoServiceMethodInterceptor());

        EchoService echoService = (EchoService) proxyFactory.getProxy();

        // class com.sun.proxy.$Proxy0
        System.out.println(echoService.getClass());
        System.out.println(echoService.echo("Hello,World"));
    }
}
